<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Salle extends Application_Model_ModelAbstract
{

    /**
     * Database var type varchar(6)
     *
     * @var string
     */
    protected $_IdSalle;

    /**
     * Database var type int(100)
     *
     * @var int
     */
    protected $_CapaciteSalle;

    /**
     * Database var type int(3)
     *
     * @var int
     */
    protected $_EtablissementIdEtab;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_RolesIdroles;


    /**
     * Parent relation fk_salle_etablissement1
     *
     * @var Application_Model_Etablissement
     */
    protected $_Etablissement;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_salle'=>'IdSalle',
            'capacite_salle'=>'CapaciteSalle',
            'etablissement_id_etab'=>'EtablissementIdEtab',
            'roles_idroles'=>'RolesIdroles',
        ));

        $this->setParentList(array(
            'FkSalleEtablissement1'=> array(
                    'property' => 'Etablissement',
                    'table_name' => 'Etablissement',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column id_salle
     *
     * @param string $data
     * @return Application_Model_Salle
     */
    public function setIdSalle($data)
    {
        $this->_IdSalle = $data;
        return $this;
    }

    /**
     * Gets column id_salle
     *
     * @return string
     */
    public function getIdSalle()
    {
        return $this->_IdSalle;
    }

    /**
     * Sets column capacite_salle
     *
     * @param int $data
     * @return Application_Model_Salle
     */
    public function setCapaciteSalle($data)
    {
        $this->_CapaciteSalle = $data;
        return $this;
    }

    /**
     * Gets column capacite_salle
     *
     * @return int
     */
    public function getCapaciteSalle()
    {
        return $this->_CapaciteSalle;
    }

    /**
     * Sets column etablissement_id_etab
     *
     * @param int $data
     * @return Application_Model_Salle
     */
    public function setEtablissementIdEtab($data)
    {
        $this->_EtablissementIdEtab = $data;
        return $this;
    }

    /**
     * Gets column etablissement_id_etab
     *
     * @return int
     */
    public function getEtablissementIdEtab()
    {
        return $this->_EtablissementIdEtab;
    }

    /**
     * Sets column roles_idroles
     *
     * @param string $data
     * @return Application_Model_Salle
     */
    public function setRolesIdroles($data)
    {
        $this->_RolesIdroles = $data;
        return $this;
    }

    /**
     * Gets column roles_idroles
     *
     * @return string
     */
    public function getRolesIdroles()
    {
        return $this->_RolesIdroles;
    }

    /**
     * Sets parent relation EtablissementIdEtab
     *
     * @param Application_Model_Etablissement $data
     * @return Application_Model_Salle
     */
    public function setEtablissement(Application_Model_Etablissement $data)
    {
        $this->_Etablissement = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_etab'];
        }

        $this->setEtablissementIdEtab($primary_key);

        return $this;
    }

    /**
     * Gets parent EtablissementIdEtab
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Etablissement
     */
    public function getEtablissement($load = true)
    {
        if ($this->_Etablissement === null && $load) {
            $this->getMapper()->loadRelated('FkSalleEtablissement1', $this);
        }

        return $this->_Etablissement;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Salle
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Salle());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Salle::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdSalle() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_salle = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdSalle()));
    }
}
